/**
 * 
 */
package com.aceitunaproject.webclient.client;

import java.util.LinkedList;
import java.util.List;

import com.aceitunaproject.shared.gamelement.Unit;
import com.aceitunaproject.shared.map.MapTile;

import gwt.gwtisometricboard.client.model.Thing;
import gwt.gwtisometricboard.client.model.Tile;

/**
 * @author Federico Bergstein
 * 
 */
public class WebTile implements Tile {

	private int x;
	private int y;
	private List<Thing> thingList = new LinkedList<Thing>();
	private String basicTileType;
	private MapTile fullTile;

	public WebTile(MapTile fullTile) {
		this.fullTile = fullTile;
		this.basicTileType = fullTile.getTerrain().get(0).getName();
		this.x = fullTile.getPosx();
		this.y = fullTile.getPosy();
		
		for (Unit theUnit : fullTile.getUnits()) {

			WebThing t = new WebThing(theUnit.getName());
			this.thingList.add(t);
		}

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see gwt.gwtisometricboard.client.model.Tile#getX()
	 */
	@Override
	public int getX() {

		return x;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see gwt.gwtisometricboard.client.model.Tile#getY()
	 */
	@Override
	public int getY() {

		return y;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see gwt.gwtisometricboard.client.model.Tile#getThingList()
	 */
	@Override
	public List<Thing> getThingList() {

		return thingList;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see gwt.gwtisometricboard.client.model.Tile#getBasicTileType()
	 */
	@Override
	public String getBasicTileType() {
		// TODO Auto-generated method stub
		return basicTileType;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * @param basicTileType
	 *            the basicTileType to set
	 */
	public void setBasicTileType(String basicTileType) {
		this.basicTileType = basicTileType;
	}

	/**
	 * @return the fullTile
	 */
	public MapTile getFullTile() {
		return fullTile;
	}

}
